package com.yssw.account.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yssw.common.annotation.Log;
import com.yssw.common.core.controller.BaseController;
import com.yssw.common.core.domain.AjaxResult;
import com.yssw.common.enums.BusinessType;
import com.yssw.account.domain.AccountItem;
import com.yssw.account.service.IAccountItemService;
import com.yssw.common.utils.poi.ExcelUtil;
import com.yssw.common.core.page.TableDataInfo;

/**
 * 财务子Controller
 * 
 * @author yssw
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/account/accountItem")
public class AccountItemController extends BaseController
{
    @Autowired
    private IAccountItemService accountItemService;

    /**
     * 查询财务子列表
     */
    @PreAuthorize("@ss.hasPermi('account:accountItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(AccountItem accountItem)
    {
        startPage();
        List<AccountItem> list = accountItemService.selectAccountItemList(accountItem);
        return getDataTable(list);
    }

    /**
     * 导出财务子列表
     */
    @PreAuthorize("@ss.hasPermi('account:accountItem:export')")
    @Log(title = "财务子", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccountItem accountItem)
    {
        List<AccountItem> list = accountItemService.selectAccountItemList(accountItem);
        ExcelUtil<AccountItem> util = new ExcelUtil<AccountItem>(AccountItem.class);
        util.exportExcel(response, list, "财务子数据");
    }

    /**
     * 获取财务子详细信息
     */
    @PreAuthorize("@ss.hasPermi('account:accountItem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(accountItemService.selectAccountItemById(id));
    }

    /**
     * 新增财务子
     */
    @PreAuthorize("@ss.hasPermi('account:accountItem:add')")
    @Log(title = "财务子", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccountItem accountItem)
    {
        return toAjax(accountItemService.insertAccountItem(accountItem));
    }

    /**
     * 修改财务子
     */
    @PreAuthorize("@ss.hasPermi('account:accountItem:edit')")
    @Log(title = "财务子", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccountItem accountItem)
    {
        return toAjax(accountItemService.updateAccountItem(accountItem));
    }

    /**
     * 删除财务子
     */
    @PreAuthorize("@ss.hasPermi('account:accountItem:remove')")
    @Log(title = "财务子", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(accountItemService.deleteAccountItemByIds(ids));
    }
}
